/* Copyright - Apache License 2.0
 * 
 * The project "kyou" is
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.kyou.pack;

import java.io.ByteArrayInputStream;

import junit.framework.Assert;

import org.junit.Test;

public class StyleItemTest {
    StyleSpecification spec = new StyleSpecification(new ByteArrayInputStream("<?xml version=\"1.0\" encoding=\"utf-8\"?><spec><config><encoding>utf-8</encoding></config></spec>".getBytes()));

    @Test
    public void test() {

        String xml = "<style target=\"#\">\r\n<text>asdf</text>\r\n</style>";

        StyleItem style = new StyleItem(UTILS.prepareElement(xml), spec);

        Assert.assertEquals(1, style.segments.length);
    }

    @Test
    public void test2() {
        String xml = "<style target=\"#\">asdf</style>";

        StyleItem style = new StyleItem(UTILS.prepareElement(xml), spec);

        Assert.assertEquals(1, style.segments.length);
    }

    @Test
    public void test3() {
        String xml = "<style target=\"#\">&lt;<str>n</str>&gt;<str>v</str>&lt;/<str>n</str>&gt;</style>";

        StyleItem style = new StyleItem(UTILS.prepareElement(xml), spec);

        Assert.assertEquals(7, style.segments.length);
    }
}
